package com.qf.spring004.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
//环绕通知
//导的包是org.aopalliance.intercept
public class MyMethodAdvice implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        // 在调用目标方法之前的逻辑
        final long start = System.currentTimeMillis();

        // 让目标方法运行  .proceed()
        final Object result = methodInvocation.proceed();

        // 调用目标方法之后的逻辑
        final long end = System.currentTimeMillis();

        System.out.println("消耗的时间为:"+(end-start));

        return result;
    }
}
